package com.ojoin.ojoin.eb_spider.domain;

import com.ojoin.trade.common.utils.CommonUtils;

public class BankCardCheck {

	
	/**
	 * 被删除
	 */
	public final static String DELETED = "deleted";

	/**
	 * 绑定使用中
	 */
	public final static String INUSE = "inUse";

	/**
	 * 待使用
	 */
	public final static String READY = "ready";

	/**
	 * 天猫平台账号
	 */
	private Integer platformAccountId;

	/**
	 * 开户行
	 */
	private String bankOfDeposit;

	/**
	 * 银行账号
	 */
	private String bankNum;

	/**
	 * 卡号状态
	 */
	private String statues;
	
	private String statuesName ;
	
	/**
	 * 是否验证成功
	 */
	private boolean correct;

	public BankCardCheck(Integer platformAccountId, String bankOfDeposit,
			String bankNum, String statues,String statuesName) {
		this.platformAccountId = platformAccountId;
		this.bankOfDeposit = bankOfDeposit;
		this.bankNum = bankNum;
		this.statues = statues;
		this.statuesName = statuesName;
	}

	public BankCardCheck() {
		
	}
	public String getBankOfDeposit() {
		return bankOfDeposit;
	}

	public void setBankOfDeposit(String bankOfDeposit) {
		this.bankOfDeposit = bankOfDeposit;
	}

	public String getBankNum() {
		return bankNum;
	}

	public void setBankNum(String bankNum) {
		this.bankNum = bankNum;
	}

	public String getStatues() {
		return statues;
	}

	public void setStatues(String statues) {
		this.statues = statues;
	}

	public Integer getPlatformAccountId() {
		return platformAccountId;
	}

	public void setPlatformAccountId(Integer platformAccountId) {
		this.platformAccountId = platformAccountId;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		
		int bankNumCode=0;
		if(bankNum != null && bankNum.length()>=4){
			bankNumCode=bankNum.substring(bankNum.length() -4, bankNum.length()).hashCode();
		}
		
		result = prime * result + bankNumCode;
		result = prime * result + ((bankOfDeposit == null) ? 0 : bankOfDeposit.hashCode());
		return result;
	}

	 
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		
		if (obj == null) {
			return false;
		} else {

			if (obj instanceof BankCardCheck) {
				BankCardCheck c = (BankCardCheck) obj;
				
				if(!CommonUtils.isEmpty(this.getBankNum()) && this.getBankNum().length()>= 4 &&  !CommonUtils.isEmpty(c.getBankNum()) && c.getBankNum().length()>= 4) {
					String cnum = c.getBankNum().substring(c.getBankNum().length() -4, c.getBankNum().length());
					
					String tnum = this.getBankNum().substring(this.getBankNum().length() -4, this.getBankNum().length());
					
					if (tnum.equals(cnum)
							&& c.getBankOfDeposit().equals(this.getBankOfDeposit())) {
						return true;
					}
				}
				
			}
		}
		return false;
	}

	public String getStatuesName() {
		return statuesName;
	}

	public void setStatuesName(String statuesName) {
		this.statuesName = statuesName;
	}

	public boolean isCorrect() {
		return correct;
	}

	public void setCorrect(boolean correct) {
		this.correct = correct;
	}

}
